<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<%@ include file="/WEB-INF/views/include/easyui.jsp"%>
</head>
<body>
	<div>
		<form id="mainform" action="${ctx}/marketTemp/${action}" method="post"
			enctype="multipart/form-data">
			<input type="hidden" name="id" value="${mt.id }" />
			<table class="formTable"
				style="border-collapse: separate; border-spacing: 10px;">
				<tr>
					<td>模板名称：</td>
					<td><input id="tempname" name="tempname" type="text"
						value="${mt.tempname }" class="easyui-validatebox"
						data-options="width: 200,required:'required'" /></td>
				</tr>
				<tr>
					<td>模板状态：</td>
					<td><select id="status" class="easyui-combobox" name="status" data-options="required:'required'">
							<option value=""></option>
							<option value="0">可用</option>
							<option value="1">禁用</option>
					</select></td>
				</tr>
				<tr>
					<td>模板大图：</td>
					<td><input id="imgurl" name="imgurl" type="file"
						class="easyui-validatebox" data-options="width: 350,required:'required'"
						readonly="readonly" /> <input id="eimg" name="eimg"
						class="easyui-validatebox" data-options="width: 350"
						onclick="edit()" readonly="readonly" /></td>
				</tr>
				<tr>
					<td>模板小图：</td>
					<td><input id="simgurl" name="simgurl" type="file"
						class="easyui-validatebox" data-options="width: 350,required:'required'"
						readonly="readonly" /> <input id="seimg" name="seimg"
						class="easyui-validatebox" data-options="width: 350"
						onclick="sedit()" readonly="readonly" /></td>
				</tr>
				<tr>
					<td>模板地址：</td>
					<td><input id="tempurl" name="tempurl" type="text"
						value="${mt.tempurl }" class="easyui-validatebox"
						data-options="width: 350,required:'required'" /></td>
				</tr>
			</table>
		</form>
	</div>
	<script type="text/javascript">
		$('#status').combobox({
			width : 200,
			panelHeight : 100
		});
		var action = "${action}";

		if (action == 'update') {
			$("#imgurl").hide();
			$('#imgurl').validatebox({    
			    required: false   
			});  
			$("#eimg").attr("value", '${mt.imgurl }');
			$("#simgurl").hide();
			$('#simgurl').validatebox({    
			    required: false   
			});  
			$("#seimg").attr("value", '${mt.simgurl }');
			$('#status').combobox('setValue', '${mt.status }');
		} else {
			$("#eimg").hide();
			$("#seimg").hide();
		}
		function edit() {
			$("#eimg").hide();
			$("#imgurl").show(); 
			$('#imgurl').validatebox({    
			    required: true   
			});  
			$("#eimg").attr("value", '');
		}
		function sedit() {
			$("#seimg").hide();
			$("#simgurl").show();
			$('#simgurl').validatebox({    
			    required: true   
			});
			$("#seimg").attr("value", '');
		}
		$('#mainform').form({
			onSubmit : function() {
				var isValid = $(this).form('validate');
				return isValid; // 返回false终止表单提交
			},
			success : function(data) {
				successTip(data, dg, d);
			}
		});
	</script>
</body>
</html>